package com.gyh.bootmybatis.dao;

import com.gyh.bootmybatis.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {

    public List<Book> findAllBooks(Book book);  //查询所有书

    @Select("select * from book where id=#{id}")
    public Book findBookById(Integer id);  //根据id号查找一本书

    @Insert("insert into book values(null,#{name},#{price},#{category},#{pnum},#{imgurl},#{description},#{author},#{sales})")
    public Integer addBook(Book book);   //添加一本书

    @Update("update book set name=#{name},price=#{price},category=#{category}, " +
            "pnum=${pnum},imgurl=#{imgurl},description=#{description}," +
            "author=#{author},sales=#{sales} where id=#{id}")
    public Integer updateBook(Book book);  //修改一本书


    public void deleteBooks(Integer[] ids);

}